Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
abdishakoor-dev
left a comment
There was a problem hiding this comment.
You found all the real dead code: greetingStr and the line after return in exercise 1, and capitalisedPets and logPets in exercise 2. The trouble is that more than the dead code has gone, so neither file prints what it did before.
Before I can mark this Complete:
exercise-1.jsnow prints nothing. The starter printedhello, Aman!, and that final log is what the dead code was being removed around. See my comment on line 6.exercise-2.jsshould still print{ HAMSTER: 3, HORSE: 1 }from thepetsarray, andcountAndCapitalisePetsshould still count whatever array it is given. See my comments on lines 4, 10 and 25.- PR tidy-up: add
CYF-1066under a "Task code" heading in the description, update the title toLondon | 26-ITP-Sep | Russom Gebremeskel | Sprint 3 | Dead Code(you're in the September cohort now, and this task is Sprint 3), and remove theNotCourseworklabel. That label tells volunteers the PR isn't coursework and to skip it; the bot's message was asking for the task code, not that label.
Add the Needs Review label again once you've pushed.
| const greetingStr = greeting + ", " + name + "!"; | ||
| return `${greeting}, ${name}!`; | ||
| console.log(greetingStr); | ||
| } |
There was a problem hiding this comment.
Run node dead-code/exercise-1.js on main and on your branch. What does each print? Dead code is code that never affects the output, so was console.log(greetingMessage) dead?
| @@ -2,27 +2,24 @@ | |||
| // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. | |||
|
|
|||
| const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; | |||
There was a problem hiding this comment.
Where is pets used now?
| } | ||
| }); | ||
| petsArr | ||
| .filter((pet) => pet[0] === "h") |
There was a problem hiding this comment.
The comment on line 2 says this function should keep working for any reasonable input. What does countAndCapitalisePets(["dog", "cat", "dog"]) return on main, and what does it return now?
|
|
||
| console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log | ||
| const animals = ["lion", "hyena", "elephant", "hippo", "tiger", "hippo"]; | ||
| console.log(countAndCapitalisePets(animals)); |
There was a problem hiding this comment.
The starter's final log printed { HAMSTER: 3, HORSE: 1 }. What does yours print, and which array is it counting?
Learners, PR Template
Self checklist
Changelist
Unused code remove. Function refactored to continue to work for any input it's given.